package com.person.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.person.daoImpl.AdminDaoImpl;
import com.person.vo.Article;

/**
 * Servlet implementation class ArticleTitleFzzyQueryServlet
 */
@WebServlet("/ArticleTitleFzzyQueryServlet")
public class ArticleTitleFzzyQueryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ArticleTitleFzzyQueryServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.print("I getted here!");
		
		response.setContentType("text/html; charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String title = (String)request.getParameter("search");
		
		List<Article> lists = null;
		
		AdminDaoImpl adi = new AdminDaoImpl();
		lists = adi.articleFzzyQueryByTitle(title);
		
		int artiSum = lists.size();	//文章总数
		int pageSize = 5;			//每页最大记录数
		
		int pageSum = artiSum / pageSize;//总页数
		if(artiSum % pageSize != 0) {
			pageSum++;
		}
		
		
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
